Tools and Libraries for a Cross-Compiler

Contents|Index|Previous|Next
Tools and libraries for a cross-compiler

If you have a cross-assembler and cross-linker available, you should install them now. Put them in the directory, /usr/local/target/bin. What follows are the tools you should put in this directory.

- as
This should be the cross-assembler.
- ld
This should be the cross-linker.
- ar
This should be the cross-archiver: a program which can manipulate archive files (linker libraries) in the target machine’s format.
- ranlib
This should be a program to construct a symbol table in an archive file.

The installation of GNU CC will find these programs in that directory, and copy or link them to the proper place to for the cross-compiler to find them when run later.

The easiest way to provide these files is to build the Binutils package and GAS. Configure them with the same ‘--host’ and ‘--target’ options that you use for configuring GNU CC, then build and install them. They install their executables automatically into the proper directory. Alas, they do not support all the targets that GNU CC supports.

If you want to install libraries to use with the cross-compiler, such as a standard C library, put them in the directory ‘/usr/local/target/lib’; installation of GNU CC copies all the files in that subdirectory into the proper place for GNU CC to find them and link with them.

The following example shows how to copy some libraries from a target-machine.

    ftp target-machine
    lcd /usr/local/target/lib
    cd /lib
    get libc.a
    cd /usr/lib
    get libg.a
    get libm.a
    quit

The precise set of libraries you’ll need, and their locations on the target machine, vary depending on its operating system.

Many targets require “start files” such as ‘crt0.o’ and ‘crtn.o’ which are linked into each executable. These too should be placed in ‘/usr/local/target/lib’. There may be several alternatives for ‘crt0.o’, for use with profiling or other compilation options. Check your target’s definition of STARTFILE_SPEC to find out what start files it uses.

The following is an example of copying these files from a target-machine.

    ftp target-machine
    lcd /usr/local/target/lib
    prompt
    cd /lib
    mget *crt*.o
    cd /usr/lib
    mget *crt*.o
    quit

Top|Contents|Index|Previous|Next